package Navi_run;

import it.unisa.dia.gas.jpbc.Element;

import java.math.BigInteger;

public class DriverTrack {
    //RSU/NSP把恶意用户的签名发给TA,这里发送了演示中注册的那个司机的签名
    public static void sendSignToTA() {
        // 获取签名
        Element REi1 = Rsu_driver.REi1.getImmutable();
        Element REi2 = Rsu_driver.REi2.getImmutable();

        BigInteger ci = Rsu_driver.ci;
        BigInteger ssi = Rsu_driver.ssi;
        //发给TA
        Rsu_TA.REi1 = REi1.getImmutable();
        Rsu_TA.REi2 = REi2.getImmutable();

        Rsu_TA.ci = ci;
        Rsu_TA.ssi = ssi;
    }


    //TA在数据库中查找恶意司机
    public static void TAresponse() {
        //TA检索数据库中的每一个ni2，然后和签名比对
        Element temp = params.pairing.pairing(Rsu_TA.REi2, params.gpk_g).mul(((params.pairing.pairing(Rsu_TA.REi1, params.gpk_A)).negate()));
        Element temp2 = params.pairing.pairing(Rsu_TA.REi1, TA_driver.ni2).getImmutable();
        if (temp.equals(temp2)) {
            //找到恶意司机 为ni2关联的真实身份
            System.out.println("恶意司机抓到了");
        } else {
            System.out.println("没找到恶意司机");
        }
    }
}
